#include "GameStartScene.h"
#include "SimpleAudioEngine.h"
#include "common.h"
#include "GameMainScene.h"
USING_NS_CC;
GameStartScene::GameStartScene(){


}

GameStartScene::~GameStartScene(){

}

Scene* GameStartScene::createScene(){
	auto scene = Scene::create();
	auto layer = GameStartScene::create();
	scene->addChild(layer);

	return scene;
}
bool GameStartScene::init(){
	if (!Layer::init()) return false;
	
	//add resources
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("images.plist");//add pics
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("move.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("merge.wav");

	//add bg
	auto bg_sprite = Sprite::createWithSpriteFrameName("bg_blank.png");
	this->addChild(bg_sprite);
	bg_sprite->setPosition(Vec2(mysize.width*0.5,mysize.height*0.5));

	//add start button
	auto start_frame = Sprite::createWithSpriteFrameName("btn_start.png");
	auto start_frame_pressed = Sprite::createWithSpriteFrameName("btn_start.png");
	start_frame_pressed->setColor(Color3B(123,123,123));
	auto start_item = MenuItemSprite::create(start_frame,start_frame_pressed,CC_CALLBACK_1(GameStartScene::startCallBack,this));

	auto menu = Menu::create(start_item,nullptr);
	this->addChild(menu);



	return true;
}
void GameStartScene::startCallBack(Ref* pSender){

	log("start button called");
	CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("move.wav");

	auto scene = GameMainScene::createScene();
	Director::getInstance()->replaceScene(scene);

}